package cn.hp.controller;

import cn.hp.entity.LoginInfor;
import cn.hp.service.ILoginInforService;
import cn.hp.util.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/loginInfor")
@Api(value = "/logininfo", tags = "登录记录")
public class LoginInforController {
    @Autowired
    private ILoginInforService loginInforService;

    @GetMapping("/find")
    @ResponseBody
    @ApiOperation(value = "查询",notes = "查询公告")
    public Result find(LoginInfor obj) {
        List<LoginInfor> loginInfors = loginInforService.selectLoginInforList(obj);
        return Result.RowsSuccess(loginInfors, loginInfors.size());
    }

    /**
     * 条件+分页查询
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询",notes = "分页查询所有公告")
    @ResponseBody
    public Result findPage(LoginInfor obj, @RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "limit", defaultValue = "10") Integer limit) {
        System.out.println(obj);
        PageInfo<LoginInfor> loginInforPageInfo = loginInforService.selectLoginInforList(obj, page, limit);
        return Result.RowsSuccess(loginInforPageInfo);
    }
}
